<template>
  <div class="container">
    <ul class="main">
      <article-item
        v-for="item in items"
        :key="item.id"
        :item="item"
        :auditId="auditId"
      />
    </ul>
    <div class="more">
      <div v-if="haveMore" style="vertical-align: middle; display: table-cell">
        <el-button @click="showMore" type="primary">点击查询更多</el-button>
      </div>
      <div
        v-else
        style="vertical-align: middle; display: table-cell; margin-left: 5px"
      >
        已无更多
      </div>
    </div>
  </div>
</template>

<script>
import articleItem from "@/views/article/component/titleItem.vue";

export default {
  name: "articleList",
  components: {
    articleItem,
  },
  props: ["items", "haveMore"],
  data() {
    return {
      // 一个记录当前列表下被审核的item的id值
      auditId: "",
    };
  },
  methods: {
    showMore() {
      this.$emit("showMore");
    },
    // 一个让list下所有item共享状态的全局事件总线(用vuex也是一个解决办法)
    setItemStatus(itemId) {
      this.auditId = itemId;
    },
  },
  mounted() {
    this.$bus.$on("setItemStatus", this.setItemStatus);
  },
};
</script>

<style scoped>
.container {
  height: 100%;
}
.more {
  display: table;
  height: 11%;
}

.main {
  margin: 0px;
  padding: 0px;
  overflow: scroll;
  margin-left: 0px;
  height: 89%;
  border: 1px solid #ddd;
  border-radius: 2px;
}
</style>